#include <iostream>
#include <unistd.h>
#include <stdlib.h>
using std::cout;
using std::endl;

int val = 100;
int main()
{
  if(fork() == 0){
    //child
    int cut = 5;
    while(cut--){
      cout << "I am a child,val =  " << val << "&val = " << &val << endl;
      sleep(1);
      if(cut == 3){
          val = 200;
      }
    }
  }
  else{
    //parent
    int cut = 5;
    while(cut--){
      cout << "I am a parent,val =  " << val << "&val = " << &val << endl;
      sleep(1);
    }
  }
  return 0;
}
